package com.lagou.homework3;

public class Ticket extends Thread {
    private static int tickets = 100;
    @Override
    public void run() {
        while (true) {
            synchronized (Ticket.class) {
                if (tickets <=0) {
                    break;
                }
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println(getName() + "这是第" + (tickets--) + "号票");
            }
        }
    }
}
